# 第 0014 题： 纯文本文件 student.txt为学生信息, 里面的内容（包括花括号）如下所示：
# 参考：https://www.pythonexcel.com/
# 参考：https://www.cnblogs.com/programmer-tlh/p/10461353.html
from  openpyxl import  Workbook 
import string
import json

def student_excle(studentDate,title,target):
    wb = Workbook()
    ws=wb.active
    ws.title=title
    for k,v in studentDate.items():
        ws[string.ascii_uppercase[0]+k]=k
        for i,x in enumerate(v):
            ws[string.ascii_uppercase[i+1]+k]=x
    wb.save(target)



if __name__=='__main__':
    with open('resource/excel/student.txt',encoding='utf-8') as f:
        studentDate=json.load(f)
        print(studentDate)
        student_excle(studentDate,'student','resource/excel/student.xlsx')
    
